//
// Created by LiuYou on 2021/5/9.
//

#include <cstdio>
#include <cstdlib>


// 加static的原因: 将函数局部化。
static void hook1() {
    std::puts("hook1() is working.");
}

static void hook2() {
    std::puts("hook2() is working.");
}

static void hook3() {
    std::puts("hook3() is working.");
}

int main(int argc, char** argv) {

    std::puts("Begin!");

    // 下面三行代码不是代表hooki函数调用。只是将hooki挂到钩子上。
    std::atexit(hook1);
    std::atexit(hook2);
    std::atexit(hook3);


    std::puts("End!");


    std::exit(0);
    // 运行结果:
//    /home/lucas/CLionProjects/LinuxEnvironmentProgramming/cmake-build-debug/FileSystemTest10
//    Begin!
//    End!
//    hook3() is working.
//    hook2() is working.
//    hook1() is working.
//
//    Process finished with exit code 0

}